package com.example.carrierapp.util;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

/**
 * Created by Administrator on 2016/12/7.
 */
public class CheckNetUtils {
    public static boolean CheckNetWork(Context context) {
        boolean isNETWORK;
        ConnectivityManager cm = (ConnectivityManager) context.getSystemService(context.CONNECTIVITY_SERVICE);
        NetworkInfo ni = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
        boolean isWIFI = ni.isConnected();
        ni = cm.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
        boolean isMOBILE = ni.isConnected();
        if (isWIFI == false && isMOBILE == false) {
            isNETWORK = false;
        } else {
            isNETWORK = true;
        }
        return isNETWORK;
    }
}
